package com.letu.core.model;

import com.letu.annotation.base.BaseEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

/**
 * <p>
 *  BUSIN业务系统，basic基础服务
 * </p>
 *
 * @author ligang
 * @date 2022-08-01
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "DataScopeEnum", description = "BUSIN业务系统，COMMON 公共服务")
public enum SystemTagEnum implements BaseEnum {

    /**
     * BUSIN="业务系统"
     */
    BUSINESS("业务系统"),
    /**
     * BASIC="基础服务"
     */
    COMMON("基础服务")
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static SystemTagEnum match(String val, SystemTagEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static SystemTagEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(SystemTagEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "PROJECT,SUB_SYSTEM,TEAM", example = "PROJECT")
    public String getCode() {
        return this.name();
    }

}
